package com.dai.zhenfujin.my.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.dai.zhenfujin.Constants.Constants;
import com.dai.zhenfujin.R;
import com.dai.zhenfujin.base.BaseActivity;
import com.dai.zhenfujin.bean.ProInfoBean;
import com.dai.zhenfujin.http.CallBack;
import com.dai.zhenfujin.http.HttpClient;
import com.dai.zhenfujin.utils.UIUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 意见反馈
 */

public class FeedbackActivity extends BaseActivity {

    private TextView title_textview;
    private FrameLayout fl_img;
    private EditText tv_connect;
    private Button sumit_idea;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.feed_back_activity);
        initView();
    }

    private void initView() {
        title_textview = findViewById(R.id.title_textview);
        fl_img = findViewById(R.id.fl_img);
        tv_connect = findViewById(R.id.et_content);
        sumit_idea = findViewById(R.id.sumit_idea);
        title_textview.setText("意见反馈");
        fl_img.setOnClickListener(v -> finish());
        sumit_idea.setOnClickListener(v -> {
            setFeedback();
        });
    }

    private void setFeedback() {
        if (TextUtils.isEmpty(tv_connect.getText().toString().trim())){
            UIUtils.showToastSafe("请输入意见内容");
            return;
        }

        Map<String, Object> params = new HashMap<>();
        Map<String, Object> params2 = new HashMap<>();
        params2.put("fb_text", tv_connect.getText().toString().trim());
        params.put("req_bd", params2);
        HttpClient.post(FeedbackActivity.this, Constants.SAVEFEEDBACK, params, new CallBack<ProInfoBean>() {
            @Override
            public void onSuccess(ProInfoBean proInfoBean) {
                UIUtils.showToastSafe("提交成功");
                finish();
            }
        });
    }
}
